//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.cvs.web.interceptor;

import cn.cvs.pojo.SysUser;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SysInterceptor extends HandlerInterceptorAdapter {
    private Logger logger = Logger.getLogger(SysInterceptor.class);

    public SysInterceptor() {
    }

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        this.logger.debug("进入自定义拦截器==>SysInterceptor");
        HttpSession session = request.getSession();
        SysUser sysUser = (SysUser)session.getAttribute("userSession");
        if (null == sysUser) {
            response.sendRedirect(request.getContextPath() + "/401.jsp");
            return false;
        } else {
            return true;
        }
    }
}
